package mysql

import "gorm.io/gorm"

// 用户表
type User struct {
	gorm.Model
	Mobile   string `gorm:"type:char(11);not null;comment:手机号;unique"`
	Password string `gorm:"type:varchar(32);not null;comment:密码"`
}

// 实名表
type RealName struct {
	gorm.Model
	UserId   int    `gorm:"int(10);not null;comment:用户id"`
	IdCard   string `gorm:"type:char(18);not null;comment:身份证号码"`
	RealName string `gorm:"type:varchar(10);not null;comment:真实姓名"`
}

func (ur *RealName) GetByUserIdOrIdCard(userId int, idCard string) error {
	return DB.Where("user_id = ? or id_card = ?", userId, idCard).Limit(1).Find(&ur).Error
}
func (ur *RealName) Add() error {
	return DB.Create(&ur).Error
}
